from small one page howto to huge articles all in one place
 

search text in:





Poll
Which linux distribution do you use?







poll results

Last additions:
using iotop to find disk usage hogs

using iotop to find disk usage hogs

words:

887

views:

196691

userrating:

average rating: 1.7 (102 votes) (1=very good 6=terrible)


May 25th. 2007:
Words

486

Views

252318

why adblockers are bad


Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

Workaround and fixes for the current Core Dump Handling vulnerability affected kernels

words:

161

views:

141290

userrating:

average rating: 1.4 (42 votes) (1=very good 6=terrible)


April, 26th. 2006:

Druckversion . pdf icon
You are here: System->Tips and Tricks

Using 'make' for backups

Thanks to Lars Weiler for providing this tip.

Usualy make from sys-devel/make is known as a tool for compiling applications. But it could also be used to provide often used commands so that they can be accessed easily.

Quite everybody wants to do backups. This could be done by packing them with tar. For instance, we want to pack the ~/Mail folder and name the file with a date:
Code Listing 1: tar ~/Mail with date included

$ tar cvjf ~/Backups/Mail-`date +%F`.tar.bz2 ~/Mail

After that we copy that file (and possibly more) to another computer by using rsync and delete all the files in ~/Backups afterwards:
Code Listing 2: Copy backup-file to another computer with rsync

$ rsync -avute ssh ~/Backups/ user@othermachine:~/Backups/
% rm ~/Backups/*

And now comes the clue with make. After a week you already forgot the commands. Why not store them in a Makefile located in the home-directory, so that you only have to call make backup?

Inside the Makefile (beware of the uppercased 'M') we provide two targets for the commands, so that we can call them separately, e.g. if you only want to copy the files. The first target backup will only call the other targets in the given order:

Code Listing 3: Sample Makefile for backups

backup: compress copy

compress:

        tar cvjf ~/Backups/Mail-`date +%F`.tar.bz2 ~/Mail
copy:
        rsync -avute ssh ~/Backups/ user@othermachine:~/Backups/
        rm ~/Backups/*

Now we can call make backup in the home directory and the ~/Mail-folder will be compressed and copied to the other computer. The restore-command-set will be your homework ;-)

Of course, there is a wide use for batched processes with Makefiles. Think about all the things you ever wanted to have scripted with easy usability. You can find more instructions in the info make pages.


rate this article:
current rating: average rating: 1.3 (51 votes) (1=very good 6=terrible)
Your rating:
Very good (1) Good (2) ok (3) average (4) bad (5) terrible (6)

back





Support us on Content Nation
rdf newsfeed | rss newsfeed | Atom newsfeed
- Powered by LeopardCMS - Running on Gentoo -
Copyright 2004-2020 Sascha Nitsch Unternehmensberatung GmbH
Valid XHTML1.1 : Valid CSS : buttonmaker
- Level Triple-A Conformance to Web Content Accessibility Guidelines 1.0 -
- Copyright and legal notices -
Time to create this page: 62.8 ms